package com.pkk.cloud.support.service.controller;

import com.pkk.cloud.support.admin.oauth2.api.admin.AdminApi;
import com.pkk.cloud.support.admin.oauth2.api.common.req.PenguinSysUserNameReq;
import com.pkk.components.rpc.request.CommonRequest;
import com.pkk.components.rpc.request.RequestHeader;
import com.pkk.components.rpc.response.CommonResponse;
import com.pkk.components.rpc.response.util.ResponseUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @description:
 * @author: peikunkun
 * @create: 2019-08-09 11:27
 **/
@RestController
@RequestMapping("user")
public class UserServiceController {


  @Autowired
  private AdminApi adminApi;


  @RequestMapping("test")
  private CommonResponse test(String u,String c) {
    //根据用户名和客户端获取用户信息
    CommonRequest<PenguinSysUserNameReq> reqCommonRequest = new CommonRequest<>(new RequestHeader(), PenguinSysUserNameReq.builder().username(u).clientId(c).build());
    return ResponseUtil.success(adminApi.loadUserByUsername(reqCommonRequest));
  }


  /**
   * @Description: 登录
   * @Param: []
   * @return: java.lang.String
   * @Author: peikunkun
   * @Date: 2019/8/9 0009 上午 11:29
   */
  @RequestMapping("login")
  public CommonResponse<Object> login() {
    return ResponseUtil.success();
  }
}
